package com.java8.lambda;

import java.util.function.Predicate;

/**
 * @Author HBZ
 * @Date 2020/8/14 23:27
 * @Description
 */
public class ValidatorTest {
    public static void main(String[] args) {
        // 原方式
        Validator numericValidator = new Validator(new IsNumeric());
        boolean b1 = numericValidator.validate("aaaa");
        Validator lowerCaseValidator = new Validator(new IsAllLowerCase());
        boolean b2 = lowerCaseValidator.validate("bbbb");
        System.out.println(b1);
        System.out.println(b2);
        // lambda方式，与Predicate方式相同
        Validator lowerCaseValidator2 =
                new Validator((String s) -> s.matches("\\d+"));
        boolean b3 = lowerCaseValidator2.validate("bbbb");
        Validator numericValidator2 =
                new Validator((String s) -> s.matches("[a-z]+"));
        boolean b4 = numericValidator2.validate("aaaa");
        System.out.println(b3);
        System.out.println(b4);

    }


}
